﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
@* <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head> *@
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">栋舍类型</label>
                    <div class="layui-input-block">
                        <select id="cottageTypeId" lay-filter="testSelect">
                            <option value="">请选择栋舍类型</option>
                            <option value="公羊舍">公羊舍</option>
                            <option value="配种舍">配种舍</option>
                            <option value="分娩舍">分娩舍</option>
                            <option value="青年舍">青年舍</option>
                            <option value="育肥舍">育肥舍</option>
                            <option value="隔离舍">隔离舍</option>
                            <option value="混合舍">混合舍</option>
                            <option value="哺乳舍">哺乳舍</option>
                            <option value="后备舍">后备舍</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">栋舍名称</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="cottageName" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">负责人</label>
                    <div class="layui-input-block">
                        <select id="persId" lay-filter="testSelect">
                            <option value="">请选择栋舍类型</option>
                            <option value="张三">张三</option>
                            <option value="李四">李四</option>
                            <option value="王五">王五</option>
                            <option value="赵六">赵六</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">生产人员</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="production" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="启用" title="启用">
                        <input type="radio" name="status" value="禁用" title="禁用">

                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline layui-input-wrap">
                        <input type="text" id="ramark" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                    </div>
                </div>

            </div>

            <div class="layui-form-item">
                <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl" onclick="Add()">保存</button>

            </div>
        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        layui.use(['table'], function () {
            var table = layui.table;
            var form = layui.form;
            var layer = layui.layer;
           
        });
    </script>
</body>

</html>

<script>
    
    function Add() {
        var data = {
            cottageTypeId: $("#cottageTypeId").val(),
            cottageName: $("#cottageName").val(),
            persId: $("#persId").val(),
            production: $("#production").val(),
            status: $("[name=status]:checked").val(),
            ramark: $("#ramark").val(),
        }

        $.ajax({
            url: "http://localhost:5123/api/Cottage/Handle",
            type: 'post',
            data: JSON.stringify(data ),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 0) {
                    layer.msg('添加成功')
                }
                else {
                    layer.msg('保存失败')
                }
            }
        })
    }
</script>
